<?php
namespace Mp\Service\Grid;

use Closure;
use Illuminate\Support\Fluent;
use Illuminate\Contracts\Support\Renderable;


class Column extends Fluent implements Renderable{

	public function __construct($params = []){
		$this->name = $params['name'] ?? $this->name;
		$this->label = $params['label'] ?? $this->name;
		$this->hidden = $params['hidden'] ?? false;
	}

	public  $name = '';

	protected $label = '';

	protected $description = '';

	protected $sortable = false;

	protected $default = '';

	protected $hidden = false;


	protected $display;

	public function __get($name){
		return $this->$name;
	}

	//渲染方法
	public function display(Closure $callback){

		$this->display = $callback;
	}

	public function render($content = ''){
		if($this->display instanceof Closure  ){
			return call_user_func( $this->display,$content);
		}else{
			return $content;
		}
		
	}

}